package com.jack.lib.net.download

import androidx.lifecycle.Lifecycle
import com.jack.lib.core.file.JFileManager
import com.jack.lib.net.download.Downloader
import java.io.File


fun Lifecycle.download(
    url: String,
    path: String = JFileManager.download,
    onSuccess: (File) -> Unit = { },
    onProcess: (Float) -> Unit = { },
    onFailed: (Throwable) -> Unit = { }
) {
    Downloader(this, url, path, onSuccess, onProcess, onFailed)
}

fun String.download(
    lifecycle: Lifecycle,
    path: String = JFileManager.download,
    onSuccess: (File) -> Unit = { },
    onProcess: (Float) -> Unit = { },
    onFailed: (Throwable) -> Unit = { }
) {
    Downloader(lifecycle, this, path, onSuccess, onProcess, onFailed)
}